package com.tudouji.project.bill.controller;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.tudouji.framework.aspectj.lang.annotation.Log;
import com.tudouji.framework.aspectj.lang.enums.BusinessType;
import com.tudouji.project.bill.domain.Producereportitem;
import com.tudouji.project.bill.service.IProducereportitemService;
import com.tudouji.framework.web.controller.BaseController;
import com.tudouji.framework.web.domain.AjaxResult;
import com.tudouji.common.utils.poi.ExcelUtil;
import com.tudouji.framework.web.page.TableDataInfo;

/**
 * 生产报明细Controller
 * 
 * @author tudouji
 * @date 2021-03-01
 */
@RestController
@RequestMapping("/bill/producereportitem")
public class ProducereportitemController extends BaseController
{
    @Autowired
    private IProducereportitemService producereportitemService;

    /**
     * 查询生产报明细列表
     */
    @PreAuthorize("@ss.hasPermi('bill:producereportitem:list')")
    @GetMapping("/list")
    public TableDataInfo list(Producereportitem producereportitem)
    {
        startPage();
        List<Producereportitem> list = producereportitemService.selectProducereportitemList(producereportitem);
        return getDataTable(list);
    }

    /**
     * 导出生产报明细列表
     */
    @PreAuthorize("@ss.hasPermi('bill:producereportitem:export')")
    @Log(title = "生产报明细", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(Producereportitem producereportitem)
    {
        List<Producereportitem> list = producereportitemService.selectProducereportitemList(producereportitem);
        ExcelUtil<Producereportitem> util = new ExcelUtil<Producereportitem>(Producereportitem.class);
        return util.exportExcel(list, "producereportitem");
    }

    /**
     * 获取生产报明细详细信息
     */
    @PreAuthorize("@ss.hasPermi('bill:producereportitem:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(producereportitemService.selectProducereportitemById(id));
    }

    /**
     * 新增生产报明细
     */
    @PreAuthorize("@ss.hasPermi('bill:producereportitem:add')")
    @Log(title = "生产报明细", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody Producereportitem producereportitem)
    {
        return toAjax(producereportitemService.insertProducereportitem(producereportitem));
    }

    /**
     * 修改生产报明细
     */
    @PreAuthorize("@ss.hasPermi('bill:producereportitem:edit')")
    @Log(title = "生产报明细", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody Producereportitem producereportitem)
    {
        return toAjax(producereportitemService.updateProducereportitem(producereportitem));
    }

    /**
     * 删除生产报明细
     */
    @PreAuthorize("@ss.hasPermi('bill:producereportitem:remove')")
    @Log(title = "生产报明细", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(producereportitemService.deleteProducereportitemByIds(ids));
    }
}
